quic: drop version negotiation packets with oversized CIDs#64228
Open
3zrv wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: Mohamed Sayed <k@3zrv.com>
6c8ce01 to
d3b996f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A single unauthenticated UDP datagram can crash a QUIC endpoint before any handshake.
When a long-header packet carries an unsupported QUIC version,
ngtcp2_pkt_decode_version_cid()returns the connection ID lengths verbatim from the single-byte length fields on the wire, it only clamps toNGTCP2_MAX_CIDLEN(20) for supported versions, so these lengths can be up to 255.In the
NGTCP2_ERR_VERSION_NEGOTIATIONbranch,Endpoint::Receive()builtCIDobjects directly from those lengths before the existing CID-length check (which sits after theswitch, on the supported-version path only).A
CIDis backed by a fixed 20-bytengtcp2_cidbuffer, so a DCID/SCID length > 20 overruns it. Because Node does not defineNDEBUG, the assert(datalen <= NGTCP2_MAX_CIDLEN) inside ngtcp2_cid_init() is compiled in and the process aborts.Fix
Extend the CID-length policy already applied to supported-version packets to the version-negotiation branch: drop packets whose decoded connection IDs exceed
NGTCP2_MAX_CIDLEN. Node's QUIC only supports v1 (CIDs ≤ 20 bytes), and the post-switch path already drops oversized-CID packets, so this is consistent with existing behavior.Test
Adds
test/parallel/test-quic-version-negotiation-oversized-cid.mjs: it sends a crafted oversized-DCID datagram vianode:dgramand asserts the endpoint drops it without crashing, while a well-formed unsupported-version datagram stillproduces exactly one Version Negotiation response.
Notes